import { ref, onMounted, onUnmounted } from 'vue';

const useMouseMoveEvent = () => {
  // var postion = { x: 0, y: 0 };
  const x = ref(0);
  const y = ref(0);
  const onMouseMoveUp = (e) => {
    // console.info("移动坐标信息：", e);
    x.value = e.pageX;
    y.value = e.pageY;
  }

  onMounted(() => {
    document.addEventListener("mousemove", onMouseMoveUp)
  })
  onUnmounted(() => {
    document.removeEventListener("mousemove", onMouseMoveUp)
  })
  return {
    x, y
  }
}

export { useMouseMoveEvent }